package com.atguigu.day06.test;

/**
 * @version 1.0
 * @Author 马冰
 * @Date 2024/11/5 15:49
 * @注释
 */
public class MethodExer {
    public static int ArrayMethod(int[] arr){
        int sum = 0;
        for(int e: arr){
            if(e%2==0){
                sum+=e;
            }
        }
        return sum;
    }

    public static boolean primeNum(int num){
        for(int i = 2; i < num; i++){
            if(num%i==0){
                return false;
            }
        }
        return true;
    }

    public static void main(String[] args) {
        for (int i = 2 ; i <= 100; i++){
            boolean flag = primeNum(i);
            if(flag){
                System.out.print(i + " ");
            }

        }
        System.out.println();
        System.out.println("----------------------------");
        int[] arr = {1,2,3,4,5,6,7,8,9};
        int sum = ArrayMethod(arr);
        System.out.println("该数组内正数的和为: " + sum);
    }
}
